/**
 * @file tfm_current_time.h
 * @author www.tuya.com
 * @brief tfm_rhythm module is used to realize rhythm function
 * @date 2022-05-26
 * @copyright Copyright (c) tuya.inc 2022
 */

#ifndef __TAL_LOCAL_TIME_H__
#define __TAL_LOCAL_TIME_H__

#include "tal_log.h"
#include "tal_memory.h"
#include "tal_sw_timer.h"
#include "tal_time_sync.h"

#ifdef __cplusplus
extern "C" {
#endif  /* __cplusplus */

#pragma pack(1)

typedef struct {
  UINT16_T tm_year;
  UINT8_T tm_mon;
  UINT8_T tm_mday;
  UINT8_T tm_hour;
  UINT8_T tm_min;
  UINT8_T tm_sec;
  UINT8_T tm_wday; //0=MON, 1=TUES, etc.
} TY_TIME_STRUCT_T;

typedef enum {
    SECOND_SINCE_1970=0,//since  1970-1-1 08:00:00
    SECOND_SINCE_2000,//since  2000-1-1 00:00:00
}TY_SECOND_SINCE_TYPE_E;

#pragma pack()

// register a report time function
typedef VOID_T (*tal_zigbee_local_time_report_time_cb_p)(VOID_T);
typedef struct _TFM_MESH_LOCAL_TIME_REPORT_TIME_S_{
    UINT16_T second;
    tal_zigbee_local_time_report_time_cb_p cb;
    struct _TFM_MESH_LOCAL_TIME_REPORT_TIME_S_ *next; 
} TFM_MESH_LOCAL_TIME_REPORT_TIME_S;

/**
 * @brief current time get
 * @param[in]current_second  current second value
 * @param[in]type  type of start count tm_sec
 * @param[out]returnTime  returns a structure for the current time, including the date, time and tm_wday
*/
VOID tal_get_current_time_struct(IN UINT32_T current_second,IN TY_SECOND_SINCE_TYPE_E type,OUT TY_TIME_STRUCT_T* returnTime);

OPERATE_RET tal_local_time_add_report(TFM_MESH_LOCAL_TIME_REPORT_TIME_S *report);

UINT8_T tal_get_local_time_bitmap(UINT8_T flag, UINT8_T *data);

VOID_T tal_local_calendar_run_hanle(VOID_T);

#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif  /* __LIHGT_PROD_H__ */
